package item.ship;

import item.defensive.DefensiveEnhancement;
import item.defensive.RandomDefensive;
import item.drone.Drone;
import item.drone.RandomAttackDrone;
import item.engine.Engine;
import item.engine.RandomEngine;
import item.mod.Mod;
import item.mod.RandomMod;
import item.weapon.RandomWeapon;
import item.weapon.Weapon;

import java.util.ArrayList;
import java.util.Random;

public class RandomCorvette {
	public static CorvetteShip random(int level) {
		Random r = new Random();
		int weight = r.nextInt(30) + level * 10;
		int condition = r.nextInt(100);
		int armor = r.nextInt(40) + level * 15;
		int hull = r.nextInt(50) + level * 15;
		int crew = r.nextInt(100) + level * 10;
		int cost = (int) ((armor + hull + crew  - weight) * condition / 100.0);
		CorvetteShip generated = new CorvetteShip(cost, weight, condition, level, armor, armor, hull, hull, crew, crew);
		
		ArrayList<Weapon> weapon = new ArrayList<Weapon>();
		for(int i = 0; i < generated.getMaxWeapon(); i++)
			weapon.add(RandomWeapon.random(level));
		
		ArrayList<DefensiveEnhancement> defense = new ArrayList<DefensiveEnhancement>();
		for(int i = 0; i < generated.getMaxDefensive(); i++)
			defense.add(RandomDefensive.random(level));
		
		ArrayList<Engine> engine = new ArrayList<Engine>();
		for(int i = 0; i < generated.getMaxEngine(); i++)
			engine.add(RandomEngine.random(level));
		
		ArrayList<Drone> drone = new ArrayList<Drone>();
		for(int i = 0; i < generated.getMaxDrone(); i++)
			drone.add(RandomAttackDrone.random(level));
		
		ArrayList<Mod> mod = new ArrayList<Mod>();
		for(int i = 0; i < generated.getMaxMod(); i++)
			mod.add(RandomMod.random(level));
		
		generated.setWeapon(weapon);
		generated.setDefensiveEnhancements(defense);
		generated.setDrone(drone);
		generated.setEngine(engine);
		generated.setMod(mod);
		
		return generated;
	}
}
